
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DimCommodity]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
 drop table [dbo].[DimCommodity]

GO

CREATE TABLE [dbo].[DimCommodity] (
	[CommodityKey] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL,
	[CommodityIdentifier] [varchar] (20) NOT NULL,
	[CommodityName] [nvarchar] (50) NOT NULL,
	[BrandName] [nvarchar] (100) NOT NULL,
	[SupplierName] [nvarchar] (100) NOT NULL,
	[ValueRange] [varchar] (50) NOT NULL,
	[Value] [numeric] (18, 3) NOT NULL,
	[IsTangible] [varchar] (3) NOT NULL,
	[CommodityLine] [int] NOT NULL,
	[ReplacementRate] [varchar] (50) NOT NULL,
	[GrossMargin] [varchar] (20) NOT NULL,
	[DurationOfSatisfaction] [varchar] (20) NOT NULL,
	[DurationOfSearch] [varchar] (20) NOT NULL,
	[Model] [varchar] (30) NOT NULL,
	[ModelVariant] [varchar] (30) NOT NULL,
	[ModelNumber] [varchar] (30) NOT NULL,
	[ManufacturerPartNumber] [varchar] (30) NOT NULL,
	[SerialNumber] [varchar] (40) NOT NULL,
	[BarcodeNumber] [varchar] (40) NOT NULL,
	[SizeRange] [varchar] (30) NOT NULL,
	[Color] [varchar] (30) NOT NULL,

	CONSTRAINT [PK_Commodity] PRIMARY KEY CLUSTERED (
		   [CommodityKey])

)

GO

grant references, select, insert, delete, update on [dbo].[DimCommodity] to [db_datawriter]

GO

grant select on [dbo].[DimCommodity] to [public]

GO

